# 设置文件和文件夹路径
$sourceFile = ".\output.docx"
$destinationFolder = "..\"

pandoc README.md -o $sourceFile --reference-doc=./template.docx --verbose   -f markdown+implicit_figures

# 获取当前日期的缩写
$currentDate = Get-Date
$year = $currentDate.Year.ToString().Substring(2)
$month = $currentDate.Month.ToString("D2")
$day = $currentDate.Day.ToString("D2")

# 获取文件扩展名
$extension = [System.IO.Path]::GetExtension($sourceFile)

# 构建新文件名
$newName = "04212094-宋景华-声音创作中音频元数据管理方法研究${year}${month}${day}${extension}"

# 重命名文件
Rename-Item -Path $sourceFile -NewName $newName -Force
# $outFile = $newName
# $workFolder = ".\temp\"
# # then this replaces table style in $outFile:
# $zipFile = $outFile.Replace(".docx",".zip")
# Rename-Item $outFile $zipFile 
# Expand-Archive $zipFile -DestinationPath $workFolder -Force
# $wordXml = Get-Content "${workFolder}Word\Document.xml"
# $updatedXml = $wordXml.Replace('<w:tblStyle w:val="Table" />','<w:tblStyle w:val="88" />')
# Set-Content -Path "${workFolder}Word\Document.xml" -Value $updatedXml
# Compress-Archive -Path "${workFolder}*" -DestinationPath $zipFile -Force
# Rename-Item $zipFile $outFile
# Remove-Item .\temp\* -Force

Remove-Item -Path "$destinationFolder\$newName" -Force
# 移动文件到目标文件夹
Move-Item -Path $newName -Destination $destinationFolder -Force

Write-Host "任务完成。"
